﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true"
	CodeBehind="RightList.aspx.cs" Inherits="SBACN.WebSite.Admin.Systems.RightList" %>

<%@ Import Namespace="SBACN.WebSite.Common" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
	<script type="text/javascript" src="/js/plugin/jquery.blockUI.js"></script>
	<script type="text/javascript">
		function ShowBlock(reset) {
			$jqy.blockUI({
				message: document.getElementById('div_Content'),
				css: {
					top: '50%',
					left: '50%',
					textAlign: 'left',
					marginLeft: (-($jqy(document.getElementById('div_Content')).width() / 2)) + 'px',
					marginTop: (-($jqy(document.getElementById('div_Content')).height() / 2)) + 'px',
					width: ($jqy(document.getElementById('div_Content')).width() + 10) + 'px',
					hight: $jqy(document.getElementById('div_Content')).height() + 'px'
				}
			});
			document.getElementById("<%= lbl_Msg.ClientID%>").innerText = "";
			if (reset) {
				document.getElementById("<%= hid_RightCode.ClientID%>").value = "";
				document.getElementById("<%= txt_Code.ClientID%>").value = "";
				document.getElementById("<%= txt_CText.ClientID%>").value = "";
				document.getElementById("<%= txt_CURL.ClientID%>").value = "";
				document.getElementById("<%= txt_EText.ClientID%>").value = "";
				document.getElementById("<%= txt_EURL.ClientID%>").value = "";
				document.getElementById("<%= txt_URL.ClientID%>").value = "";
				document.getElementById("<%= txt_Memo.ClientID%>").value = "";
				document.getElementById("<%= txt_Name.ClientID%>").value = "";
				document.getElementById("<%= txt_SortIndex.ClientID%>").value = "1";
				document.getElementById("<%= chb_IsAdmin.ClientID%>").checked = false;
				document.getElementById("<%= chb_ShowInMap.ClientID%>").checked = false;
				document.getElementById("<%= chb_Status.ClientID%>").checked = false;
				document.getElementById("<%= chb_OpenInNewWindow.ClientID%>").checked = false;
				document.getElementById("<%= chb_NeedLogin.ClientID%>").checked = false;
				$jqy("#<%= txt_Code.ClientID%>").removeAttr("disabled");
			}
		}

		function Edit(id) {
			$jqy.get("<%= RootPath%>Handler/Admin/RightHandler.ashx?id=" + id, function (data) {
				$jqy("#<%= txt_Code.ClientID%>").attr("disabled", "true");
				document.getElementById("<%= txt_Name.ClientID%>").value = data.Name;
				document.getElementById("<%= hid_RightCode.ClientID%>").value = data.Code;
				document.getElementById("<%= txt_Code.ClientID%>").value = data.Code;
				document.getElementById("<%= txt_CText.ClientID%>").value = data.CText;
				document.getElementById("<%= txt_CURL.ClientID%>").value = data.CURL;
				document.getElementById("<%= txt_EText.ClientID%>").value = data.EText;
				document.getElementById("<%= txt_EURL.ClientID%>").value = data.EURL;
				document.getElementById("<%= txt_URL.ClientID%>").value = data.AdminURL;
				document.getElementById("<%= txt_Memo.ClientID%>").value = data.Description;
				document.getElementById("<%= txt_SortIndex.ClientID%>").value = data.SortIndex;
				document.getElementById("<%= chb_IsAdmin.ClientID%>").checked = data.IsAdminRight;
				document.getElementById("<%= chb_ShowInMap.ClientID%>").checked = data.ShowInMap;
				document.getElementById("<%= chb_Status.ClientID%>").checked = data.Status;
				document.getElementById("<%= chb_NeedLogin.ClientID%>").checked = data.NeedLogin;
				document.getElementById("<%= chb_OpenInNewWindow.ClientID%>").checked = data.OpenInNewWindow;
				ShowBlock(false);
			});
		}

		function HideBlock() {
			$jqy.unblockUI();
		}
		function validInput() {
			if ($jqy.trim(document.getElementById("<%= txt_Name.ClientID%>").value).length == 0) {
				document.getElementById("<%= lbl_Msg.ClientID%>").innerText = "功能名称不能为空!";
				$jqy("#<%= txt_Name.ClientID%>").focus();
				return false;
			}

			if ($jqy.trim(document.getElementById("<%= txt_Code.ClientID%>").value).length == 0) {
				document.getElementById("<%= lbl_Msg.ClientID%>").innerText = "系统代码不能为空!";
				$jqy("#<%= txt_Code.ClientID%>").focus();
				return false;
			}

			if ($jqy.trim(document.getElementById("<%= txt_CText.ClientID%>").value).length == 0) {
				document.getElementById("<%= lbl_Msg.ClientID%>").innerText = "中文显示不能为空!";
				$jqy("#<%= txt_CText.ClientID%>").focus();
				return false;
			}

			//			if ($jqy.trim(document.getElementById("<%= txt_URL.ClientID%>").value).length == 0) {
			//				document.getElementById("<%= lbl_Msg.ClientID%>").innerText = "权限链接不能为空!";
			//				$jqy("#<%= txt_URL.ClientID%>").focus();
			//				return false;
			//			}

			if ($jqy.trim(document.getElementById("<%= txt_SortIndex.ClientID%>").value).length == 0 && isNaN(document.getElementById("<%= txt_SortIndex.ClientID%>").value)) {
				document.getElementById("<%= lbl_Msg.ClientID%>").innerText = "排列顺序输入不正确!";
				$jqy("#<%= txt_SortIndex.ClientID%>").focus();
				return false;
			}

			document.getElementById("<%= lbl_Msg.ClientID%>").innerText = "";
			document.getElementById("form1").appendChild(document.getElementById('div_Content'));
			return true;
		}

		function ChangeRightStatus(code) {
			document.getElementById("<%= hid_RightCode.ClientID%>").value = code;
			document.getElementById("<%= btn_ChangeStatus.ClientID%>").click();
		}
	</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table-stroke2">
		<tr>
			<td width="15%" class="form-title2" >
				功能名称
			</td>
			<td width="17%" class="form-title2">
				中文显示
			</td>
			<td width="17%" class="form-title2">
				英文显示
			</td>
			<td width="18%" class="form-title2">
				管理功能连接
			</td>
			<td width="5%" class="form-title2">
				排序
			</td>
			<td width="5%" class="form-title2">
				管理
			</td>
			<td width="5%" class="form-title2">
				会员
			</td>
			<td width="5%" class="form-title2">
				用户
			</td>
			<td width="5%" class="form-title2">
				状态
			</td>
			<td class="form-title2">
			操作
				<%--<input type="button" value="新增" style="width: 60px;" onclick="return ShowBlock(true);" />--%>
			</td>
		</tr>
		<asp:Repeater ID="rpt_Right" runat="server" EnableViewState="false">
			<ItemTemplate>
				<tr title="<%# Eval("Description")%>">
					<td class="form-body" title="<%# Eval("Code")%>" style='text-align: left; text-indent: <%# Eval("Code").ToString().Length/4 -1 %>em; <%# Eval("Code").ToString().Length == 4 ? "font-weight:bold;": ""%>'>
						<%# Eval("Name").ToString().CutTo(12, 10)%>
					</td>
					<td class="form-body" title="<%# Eval("CText")%>" >
						<%# Eval("CText").ToString().CutTo(12, 10)%>
					</td>
					<td class="form-body" title="<%# Eval("EText")%>" >
						<%# Eval("EText").ToString().CutTo(16, 14)%>
					</td>
					<td class="form-body" style="text-align: left;">
						<%# Eval("AdminURL").ToString().CutTo(33,31)%>
					</td>
					<td class="form-body">
						<%# Eval("SortIndex")%>
					</td>
					<td class="form-body">
						<%# Convert.ToBoolean(Eval("IsAdminRight")) ? "是" : "否"%>
					</td>
					<td class="form-body">
						<%# Convert.ToBoolean(Eval("NeedMemberLogin")) ? "是" : "否"%>
					</td>
					<td class="form-body">
						<%# Convert.ToBoolean(Eval("ShowInMap")) ? "是" : "否"%>
					</td>
					<td class="form-body">
						<%# Convert.ToBoolean(Eval("Status")) ? "启用" : "<font color='red'>停用</font>"%>
					</td>
					<td class="form-body">
						<a href="javascript:void(0)" onclick="return Edit('<%# Eval("Code")%>');">修改</a>&nbsp;<a
							href="javascript:void(0)" onclick="return ChangeRightStatus('<%# Eval("Code")%>')"><%# Convert.ToBoolean(Eval("Status")) ? "停用" : "启用" %></a>
					</td>
				</tr>
			</ItemTemplate>
			<AlternatingItemTemplate>
				<tr title="<%# Eval("Description")%>">
					<td class="form-label" title="<%# Eval("Code")%>" style='text-align: left; text-indent: <%# Eval("Code").ToString().Length/4 -1 %>em; <%# Eval("Code").ToString().Length == 4 ? "font-weight:bold;": ""%>'>
						<%# Eval("Name").ToString().CutTo(12, 10)%>
					</td>
					<td class="form-label" title="<%# Eval("CText")%>">
						<%# Eval("CText").ToString().CutTo(12, 10)%>
					</td>
					<td class="form-label" title="<%# Eval("EText")%>">
						<%# Eval("EText").ToString().CutTo(16, 14)%>
					</td>
					<td class="form-label" style="text-align: left;">
						<%# Eval("AdminURL").ToString().CutTo(33,31)%>
					</td>
					<td class="form-label">
						<%# Eval("SortIndex")%>
					</td>
					<td class="form-label">
						<%# Convert.ToBoolean(Eval("IsAdminRight")) ? "是" : "否"%>
					</td>
					<td class="form-label">
						<%# Convert.ToBoolean(Eval("NeedMemberLogin")) ? "是" : "否"%>
					</td>
					<td class="form-label">
						<%# Convert.ToBoolean(Eval("ShowInMap")) ? "是" : "否"%>
					</td>
					<td class="form-label">
						<%# Convert.ToBoolean(Eval("Status")) ? "启用" : "<font color='red'>停用</font>"%>
					</td>
					<td class="form-label">
						<a href="javascript:void(0)" onclick="return Edit('<%# Eval("Code")%>');">修改</a>&nbsp;<a
							href="javascript:void(0)" onclick="return ChangeRightStatus('<%# Eval("Code")%>')"><%# Convert.ToBoolean(Eval("Status")) ? "停用" : "启用" %></a>
					</td>
				</tr>
			</AlternatingItemTemplate>
		</asp:Repeater>
		<tr>
			<td colspan="10" class="form-body" align="center">
				<asp:Label ID="lbl_MainMsg" runat="server" ForeColor="Red"></asp:Label>&nbsp;
			</td>
		</tr>
		<tr>
			<td colspan="10" class="form-body" align="center">
				<input class="btnsearch" type="button" value="新增" onclick="return ShowBlock(true);" />
			</td>
		</tr>
	</table>
	<div style="display: none; padding: 5px;" id="div_Content">
		<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table-stroke2">
			<tr>
				<td width="16%" class="form-label-1">
					<span
						style="color: Red">*</span>功能名称:
				</td>
				<td width="84%" class="form-body-1">
					<asp:TextBox ID="txt_Name" runat="server" Width="330px" MaxLength="50"></asp:TextBox>
				</td>
			</tr>
			<tr>
				<td width="16%" class="form-label-1">
					<span
						style="color: Red">*</span>系统代码:
				</td>
				<td width="84%" class="form-body-1">
					<asp:TextBox ID="txt_Code" runat="server" Width="330px" MaxLength="50"></asp:TextBox>
				</td>
			</tr>
			<tr>
				<td width="16%" class="form-label-1">
					<span
						style="color: Red">*</span>中文显示:
				</td>
				<td width="84%" class="form-body-1">
					<asp:TextBox ID="txt_CText" runat="server" Width="330px" MaxLength="50"></asp:TextBox>
				</td>
			</tr>
			<tr>
				<td width="16%" class="form-label-1">
					中文链接:
				</td>
				<td width="84%" class="form-body-1">
					<asp:TextBox ID="txt_CURL" runat="server" Width="330px" MaxLength="200"></asp:TextBox>
				</td>
			</tr>
			<tr>
				<td width="16%" class="form-label-1">
					英文显示:
				</td>
				<td width="84%" class="form-body-1">
					<asp:TextBox ID="txt_EText" runat="server" Width="330px" MaxLength="100"></asp:TextBox>
				</td>
			</tr>
			<tr>
				<td width="16%" class="form-label-1">
					英文链接:
				</td>
				<td width="84%" class="form-body-1">
					<asp:TextBox ID="txt_EURL" runat="server" Width="330px" MaxLength="200"></asp:TextBox>
				</td>
			</tr>
			<tr>
				<td width="16%" class="form-label-1">
					管理功能连接:
				</td>
				<td width="84%" class="form-body-1">
					<asp:TextBox ID="txt_URL" runat="server" Width="330px" MaxLength="500"></asp:TextBox>
				</td>
			</tr>
			<tr>
				<td width="16%" class="form-label-1">
					<span
						style="color: Red">*</span>排列顺序:
				</td>
				<td width="84%" class="form-body-1">
					<asp:TextBox ID="txt_SortIndex" runat="server" Width="330px" Text="1" MaxLength="4"></asp:TextBox>
				</td>
			</tr>
			<tr>
				<td width="16%" class="form-label-1">
					其他设置:
				</td>
				<td width="84%" class="form-body-1">
					<asp:CheckBox ID="chb_IsAdmin" Text="管理功能" runat="server" />&nbsp;&nbsp;
					<asp:CheckBox ID="chb_NeedLogin" Text="会员功能" runat="server" />&nbsp;&nbsp;
					<asp:CheckBox ID="chb_ShowInMap" Text="用户功能" runat="server" /><br />
					<asp:CheckBox ID="chb_Status" Text="启用" runat="server" />&nbsp;&nbsp;
					<asp:CheckBox ID="chb_OpenInNewWindow" Text="在新窗口中编辑" runat="server" />
				</td>
			</tr>
			<tr>
				<td width="16%" class="form-label-1">
					说明:
				</td>
				<td width="84%" class="form-body-1">
					<asp:TextBox ID="txt_Memo" TextMode="MultiLine" Rows="4" runat="server" Width="330px"
						MaxLength="200"></asp:TextBox>
				</td>
			</tr>
			<tr>
				<td colspan="2" class="form-body-1" style="text-align: center;" align="center">
					<asp:Label ID="lbl_Msg" ForeColor="Red" runat="server">&nbsp;</asp:Label>
				</td>
			</tr>
			<tr>
				<td colspan="2" class="form-body-1" align="center" style="text-align:center;">
					<asp:Button ID="btn_Create" Text="确定"  runat="server" OnClientClick="return validInput();"
						OnClick="btn_Create_Click" CssClass="btnsearch" />&nbsp;
					<input class="btnsearch" type="button" value="取消" onclick="return HideBlock();" />
				</td>
			</tr>
		</table>
	</div>
	<div style="display: none;">
		<asp:HiddenField ID="hid_RightCode" Value="" runat="server" />
		<asp:Button ID="btn_ChangeStatus" Text="停用" Width="80px" runat="server" OnClick="btn_Delete_Click" />
	</div>
</asp:Content>
